package com.ruitu.router_module;

import com.ruitu.arad.api.RuituInterceptor;
import com.ruitu.router_module.util.Health2Interceptor;
import com.ruitu.router_module.util.HealthInterceptor;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;

// 全局配置信息
public class Config {
    public static boolean IS_DEBUG = true;

    public static final String HTTP_URL = "http://www.jbshch.com/app/";
    public static final String BASE_URL = "http://222.186.133.244:8097";
    public static final String SMS_URL = "http://222.186.133.244:8098/";
    public static final String URL = "http://222.186.133.244:8097/";
//    public static final String URL = "http://192.168.1.213:8097/";
//    public static final String BASE_URL = "http://192.168.1.1808578:8082/";

    public static final String DATE_FORMAT_STANDARD = "yyyy-MM-dd HH:mm:ss";
    public static final String DATE_FORMAT_YMD = "yyyy-MM-dd";
    public static final String DATE_FORMAT_YM = "yyyy-MM";
    public static final String DATE_FORMATE_HMS = "HH:mm:ss";
    public static final String DATE_FORMATE_HM = "HH:mm";

    static HttpLoggingInterceptor loggingInterceptor;

    public static HttpLoggingInterceptor getLoggingInterceptor() {
        if (null == loggingInterceptor) {
            loggingInterceptor = new HttpLoggingInterceptor();
        }
        if (IS_DEBUG) {
            loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        } else {
            loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.NONE);
        }
        return loggingInterceptor;
    }

    static RuituInterceptor ruituInterceptor;

    public static RuituInterceptor getRuituInterceptor() {
        if (null == ruituInterceptor) {
            ruituInterceptor = new RuituInterceptor();
        }
        return ruituInterceptor;
    }

    static HealthInterceptor healthInterceptor;

    public static HealthInterceptor getHealthInterceptor() {
        if (null == healthInterceptor) {
            healthInterceptor = new HealthInterceptor();
        }
        return healthInterceptor;
    }

    static Health2Interceptor health2Interceptor;

    public static Health2Interceptor getHealth2Interceptor() {
        if (null == health2Interceptor) {
            health2Interceptor = new Health2Interceptor();
        }
        return health2Interceptor;
    }

    static OkHttpClient client;

    public static OkHttpClient getClient() {
        if (null == client) {
            client = new OkHttpClient.Builder()
                    .addInterceptor(getHealthInterceptor())
//                    .addInterceptor(getHealth2Interceptor())
                    .addInterceptor(getLoggingInterceptor())
                    .build();
        }
        return client;
    }
}
